<?php

// 银行卡列表
class Bank_model extends CI_Model
{

    // 增加
    public function addCard($data)
    {
        return $this->db->insert('member_bank', [
            'uid' => $data['uid'],
            'name' => $data['name'],
            'number' => $data['id_card'],
            'bank_name' => $data['bank_name'],
            'time' => time(),
        ]);
    }

    // 修改
    public function editCard($id, $data)
    {
        return $this->db->set($data)->where('id', $id)->update('member_bank');
    }

    // 删除
    public function delCard($id)
    {
        return $this->db->where(['id' => $id])->delete('member_bank');
    }

    // 详情
    public function cardInfo($id)
    {
        return $this->db->select('id,uid,name,number,bank_name')
            ->where('id', $id)->get('member_bank')->row_array();
    }

    // 列表
    public function cardList($uid, $page, $pageSize)
    {
        return $this->db->select('id,name,number,bank_name')
            ->where(['uid' => $uid])->limit($pageSize, ($page - 1) * $pageSize)
            ->get('member_bank')->result_array();
    }
}